home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!tsys.demon.co.uk
- From: Tom Wheeley <tomw@tsys.demon.co.uk>
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
- Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
- Date: Thu, 11 Apr 96 03:50:58 GMT
- Organization: City Zen FM
- Message-ID: <829194658snz@tsys.demon.co.uk>
- References: <JSA.96Feb16135027@organon.com> <dewar.828936837@schonberg> <828964950snz@genesis.demon.co.uk> <dewar.828987544@schonberg> <4kbuebINNrho@keats.ugrad.cs.ubc.ca> <dewar.829048603@schonberg> <4kets3$ic0@news-s01.ny.us.ibm.net>
- Reply-To: tomw@tsys.demon.co.uk
- X-NNTP-Posting-Host: tsys.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.30
- X-Sig-By: Tomsystems Quote v1.2. (c)1996 Tom Wheeley, tomw@tsys.demon.co.uk
- X-Mail2News-Path: tsys.demon.co.uk
-
- In article <4kets3$ic0@news-s01.ny.us.ibm.net>
- mshan@ibm.net "Mike Shannon" writes:
-
- > In <dewar.829048603@schonberg>, dewar@cs.nyu.edu (Robert Dewar) writes:
- >
- > >There are two possible semantics that ould
- > >be defined for read (buffer must be at least size of the read argument,
- > >or buffer must be at least size of data read). Both are easy to specify,
- > >both are easy to implement. You cannot rely on common sense
- > > ...
- >
- > I'm a latecomer to this dispute, but this is not smart:
- >
- > char buf[100];
- >
- > read(fd,buf,1000);
- >
- > Common sense, which tells me not to do such things, is a welcome ally.
-
- Certainly, but if I have been following this correctly, the 1000 is a red
- herring which casts doubt on the programmers ability. f.e., what if some
- rogue process (or kernel!) manages to increase that files size to 680 bytes?
-
- The last argument to read is your friend. :-) If you know your file will be
- always 68 bytes, then put 68 there. Even better, as I assume you are putting
- in the 1000 as a catchall for expansion, put a #define in, and base the size
- of your buffer, and the last argument to read on that. Simple and effective.
-
- What Robert is complaining about is that he is reading a 68 byte file by
- requesting 1000 bytes; and that in his opinion, read should stop reading
- at the end of the file, and return control.
-
- Myself, I would see this auto-stop idea as a _feature_ of read(). features
- can only be relied upon portably if they are positively documented in POSIX.
- This feature is not therefore portable, as POSIX is muddy on the matter.
-
- I suppose in c.l.c speak, it would be called `implementation-defined'.
-
- .splitbung
- --
- * TQ 1.0 * The 'Just So Quotes'.
- If you keep saying things are going to be bad, you have a chance of being a
- prophet.
- -- Isaac Bashevis Singer
-